home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / misc / speak_ez.lzh / speakmeg.c < prev    next >
C/C++ Source or Header  |  1994-08-27  |  3KB  |  103 lines

  1. /*
  2.     SPEAK.TOS  -- Speak text from the standard input
  3.  
  4.     This program uses STSPEECH.TOS to speak text from the standard
  5.     input. Using file indirection, text files may also be spoken even
  6.     though the results may be somewhat unpredictable.
  7.  
  8.     THIS PROGRAM IS FOR NON-PROFIT USE ONLY!!!!!!!!! 
  9.  
  10.     This program uses two entry points into STSPEECH that allow
  11.     speech generation under program control. The process works
  12.     as follows...
  13.  
  14.     Load  "STSPEECH.TOS" into memory using the Mode 3 option
  15.         of the Pexec Gemdos call. If successful, this call will
  16.         return the address of the base page of the loaded program.
  17.         Add 0x100 to this to get the first byte of the executable
  18.         code. (Note: STSPEECH.TOS must be in the same directory as
  19.     SPEAK.TOS)
  20.  
  21.     In order to disable the prompting of STSPEECH, two RTS
  22.     instructions are placed so that two subroutines are
  23.     created. The first starts at 0x32 bytes after the program
  24.     address and converts text in STSPEECH's internal buffer
  25.     to phonemes. The second at 0x88 bytes after the program
  26.     address generates speech from the phonomes.
  27.  
  28.         Read text into the input buffer that STSPEECH uses. This
  29.     buffer is in the format that Cconrs() uses. So the first
  30.         byte of the buffer must be the length of the buffer (in
  31.     this case, 0xfe). The second byte must be the length of
  32.     input line.
  33.  
  34.     Call the subroutines for phoneme and speech generation.
  35.  
  36.         
  37.         Note: The code may look a little convoluted due to the
  38.     necessity of saving pointers that Megamax depends on and
  39.     are destroyed by STSPEECH.    
  40.  
  41.         Written by:
  42.  
  43.         Steve Bate, November 1986
  44.         ARPA: smb.mdc@office-1.arpa
  45.             AURA BBS: (314) 928-0598  (ST BBS, 20 Meg of downloads)
  46.  
  47. */
  48.  
  49.  
  50. #include <stdio.h>
  51. #include <osbind.h>
  52.  
  53. #define MEGAMAX
  54.  
  55. char rts[2] = {0x4e,0x75};
  56.  
  57. main (argc,argv)
  58. int argc;
  59. char *argv[];
  60. {
  61.  
  62.     long base;
  63.     register char *program,*buffer;
  64.  
  65.     base = Pexec(3,"stspeech.tos",NULL,NULL);
  66.     if (base < 0) exit(1);
  67.  
  68.     program = (char *)(base + 0x100);
  69.  
  70.     strncpy(program + 0x0e,rts,2);
  71.     strncpy(program + 0x6c,rts,2);
  72.  
  73.     buffer = program + 0x6eee;
  74.  
  75.     while(fgets(buffer+2,0xfe,stdin)) {
  76.        *buffer = 0xfe;
  77.        *(buffer+1) = (char)strlen(buffer+2)-1;
  78.  
  79.        /* 
  80.           STSPEECH will respeak the last line if the current
  81.           input line is a '\n'. The '\n' is replaced by a 
  82.       space to defeat this redundant speech on double spaced
  83.           files.
  84.        */
  85.  
  86.        if (!*(buffer+1)) strncpy(buffer+1,"\1 \0",3);
  87.  
  88.        asm {
  89.                 movem.l A6-A4,-(A7)
  90.         move.l    program,-(A7)
  91.                jsr    0x32(program)
  92.                 move.l  (A7),program 
  93.                 jsr     0x88(program)
  94.                 move.l  (A7)+,program
  95.                 movem.l (A7)+,A4-A6
  96.        }
  97.        buffer = program + 0x6eee;
  98.  
  99.    }
  100. }
  101.    
  102.     
  103.